﻿app.factory('categoryService', function ($http) {
    var url = "http://localhost:20700/api/Category/";
    var _getList = function () {
        return $http.get(url).then(function (results) {
            return results;
        });
    };
    var _create = function (category) {
        return $http.post(url, category).then(function (results) {
            return results;
        });
    };
    var _delete = function (id) {
        return $http.delete(url, { params: id }).then(function (results) {
            return results;
        });
    };
    var _update = function (id, category) {
        return $http({
            method: 'PUT',
            url: url + category.id,
            data: category
        }).then(function (results) {
            return results;
        });
    };
    return {
        getList: _getList,
        create: _create,
        delete: _delete,
        update: _update,
    };
});